package beans;

import java.io.Serializable;
import java.util.ArrayList;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;


@Entity
@Table(name= "Remitos")
public class Remito implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -553692335342533569L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO) 
	private int idRemito;
	
	@OneToOne (cascade=CascadeType.ALL)
	@JoinColumn(name="idOrdenCompra")
    private OrdenCompra ordenCompra;
    
	@OneToOne (cascade=CascadeType.ALL)
	@JoinColumn(name="idProveedor")
	private Proveedor proveedor;
    
	public Remito() {
		proveedor = new Proveedor();
		ordenCompra = new OrdenCompra();
	}
	
	
	
	
	public int getIdRemito() {
		return idRemito;
	}
	public void setIdRemito(int idRemito) {
		this.idRemito = idRemito;
	}
	public OrdenCompra getOrdenCompra() {
		return ordenCompra;
	}
	public void setOrdenCompra(OrdenCompra ordenCompra) {
		this.ordenCompra = ordenCompra;
	}
	public Proveedor getProveedor() {
		return proveedor;
	}
	public void setProveedor(Proveedor proveedor) {
		this.proveedor = proveedor;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + idRemito;
		result = prime * result
				+ ((ordenCompra == null) ? 0 : ordenCompra.hashCode());
		result = prime * result
				+ ((proveedor == null) ? 0 : proveedor.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Remito other = (Remito) obj;
		if (idRemito != other.idRemito)
			return false;
		if (ordenCompra == null) {
			if (other.ordenCompra != null)
				return false;
		} else if (!ordenCompra.equals(other.ordenCompra))
			return false;
		if (proveedor == null) {
			if (other.proveedor != null)
				return false;
		} else if (!proveedor.equals(other.proveedor))
			return false;
		return true;
	}
    
    
}
